home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11189 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: news.delphi.com!usenet
  2. From: JGUILLORY@delphi.com
  3. Newsgroups: comp.lang.c++
  4. Subject: BC++ 4.52 Intel Floating Point Format
  5. Date: 13 Mar 1996 03:57:02 GMT
  6. Organization: Delphi Internet Services Corporation
  7. Message-ID: <4i5h2e$5rt@news2.delphi.com>
  8. References: <31363716.17D8@lexicon.net.au>
  9. NNTP-Posting-Host: bos1g.delphi.com
  10.  
  11.  
  12. Quoting LucasGiezen<lucas from a message in comp.lang.c++
  13.    > We are developing on a PC platform and must transfer floats and doubles
  14.    > to an IBM mainframe.
  15.  
  16. MS Quick Pascal's book defines the following (which except for the 'Real'
  17. type, is the same as Turbo C/C++ and Microsoft C/C++ as well as the normal
  18. for 80x87 programming:
  19.  
  20. for each below:  s = sign, f = fractional part, e = exponent
  21.                  width designates width of fields below....
  22.                  bits designates the bit# of the field...
  23.                  I don't see any reference to what i and d are,
  24.                  perhaps you may be able to determine it somewhere
  25.                  else, but they are only used in EXTENDED and COMP,
  26.                  which are strictly used for 64bit and 79 bit Floating
  27.                  point numbers using a Math Coprocessor....
  28.  
  29. Real:
  30.  
  31. Width        1 39            8
  32. use          s-f-------------e--
  33. Bits        47-----------------0
  34.  
  35. Single:
  36.  
  37. Width       1 8     23
  38. use         s e-----f--------
  39. Bits       31---------------0
  40.  
  41. Double:
  42.  
  43. Width      1 11    52
  44. use        s e-----f--------
  45. Bits      63---------------0
  46.  
  47. Extended:
  48.  
  49. Width     1 15  1 63
  50. use       s e---i f---------
  51. Bits     79----------------0
  52.  
  53. Comp
  54.  
  55. Width    1 63
  56. use      s d------------------
  57. Bits    63-------------------0
  58.  
  59. All types assume that the units digit in the mantissa is equal to 1, such
  60. that the 4-byte single type, the value is computed as:
  61.  
  62.          (s)        (e-127)
  63.        -1    * 1.f*2
  64.  
  65. (hard to draw the box accurately in ascii but, Bit # 47 is the sign bit,
  66. the lowest 8 are the exponent, and 39 bits from 9 - 46 are for the fractional
  67. part...
  68.  
  69.    > We have done a 'study' of the internal formats using debug but around 
  70.    >0 a number of strange things occur. Add to this the byte swapping of the
  71.    > Intel chip and things really do look odd.
  72.    > Does anyone have the format of the bits in the internal representation
  73.    > for the PC? (We already have the mainframe format). Also the
  74.    > representations of 0 and other oddities would be appreciated.
  75.    > Thanks
  76.    > Brett Walker
  77.    > .
  78.  
  79. Many mainframes, and few languages will use Binary Coded Decimal, such that
  80. eg: 1234.5678 would be apear in debug would look like:
  81.  
  82.   12 34 56 78
  83.  
  84. in other words, fixed decimal point, and each digit is stored in a nibble.
  85. That's about all the formats I've seen used on PC's, let me know if you
  86. need any more info....
  87.  
  88.  
  89. John H. Guillory
  90. JGuillory@Delphi.com
  91.  
  92. "Tomato paste: Used to fix broken tomatoes."
  93.  
  94.